﻿﻿using System;
using StarTrek.Ship;
using StarTrek.Weapon;

namespace StarTrek.World
{
    public class ShipStatus //Information about enemy.
    {
        private iShip Source;

        public ShipStatus(iShip From)
        {
            Source = From;
        }

        public float Power { get { return Source.PowerUnit; } }
        public float ShieldStrength
        {
            get
            {
                Shield local = Source.GetWeapon("Shield") as Shield;
                return local.ShieldPerc;
            }
        }
        public float HullStrength
        {
            get
            {
                Repair local = Source.GetWeapon("Repair") as Repair;
                return local.HullPerc;
            }
        }
        public bool isDestoryed { get { return HullStrength <= 0; } }
        public string Name { get { return Source.ShipName; } }

        public string[] WeaponOperationalStatus()
        {
            return Source.GetWeapons().ConvertAll(new Converter<iWeapon, String>(WeaponStatus)).ToArray();
        }
        private static string WeaponStatus(iWeapon arg)
        {
            if (arg != null)
                return
                    string.Format("{0} Status: {1}", arg.GetType().Name,
                                  (arg.isFunctional ? "Operational" : "Damaged"));
            return string.Empty; // fail Safe
        }
    }
}
